#include <iostream>
#include <string>
#include <vector>
#include <cmath>

/**
 * @brief Checks if a given number is prime.
 * @param n The number to be checked.
 * @return true if the number is prime, false otherwise.
 */
bool p(int n) {
    for (int i = 2; i < n; i++) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
    std::string input;
    std::getline(std::cin, input);

    // Replace the written numbers with their numeric values
    std::string a = "";
    for (int i = 0; i < input.length(); i++) {
        if (input[i] == ' ') {
            continue;
        }
        if (input.substr(i, 4) == "zero") {
            a += "0";
            i += 3;
        }
        else if (input.substr(i, 3) == "one") {
            a += "1";
            i += 2;
        }
        else if (input.substr(i, 3) == "two") {
            a += "2";
            i += 2;
        }
        else if (input.substr(i, 5) == "three") {
            a += "3";
            i += 4;
        }
        else if (input.substr(i, 4) == "four") {
            a += "4";
            i += 3;
        }
        else if (input.substr(i, 4) == "five") {
            a += "5";
            i += 3;
        }
        else if (input.substr(i, 3) == "six") {
            a += "6";
            i += 2;
        }
        else if (input.substr(i, 5) == "seven") {
            a += "7";
            i += 4;
        }
        else if (input.substr(i, 5) == "eight") {
            a += "8";
            i += 4;
        }
        else if (input.substr(i, 4) == "nine") {
            a += "9";
            i += 3;
        }
        else {
            a += input[i];
        }
    }

    int num = std::stoi(a);

    if (num >= 100 && num <= 999) {
        std::vector<int> prost;
        for (int i = 2; i < 1000; i++) {
            if (p(i)) {
                prost.push_back(i);
            }
        }

        int mn = 10000;
        int k = 0;
        for (int i : prost) {
            if (std::abs(i - num) < mn) {
                mn = std::abs(i - num);
                k = i;
            }
        }

        std::cout << k << std::endl;
    }
    else {
        std::cout << "Wrong input" << std::endl;
    }

    return 0;
}